package com.cet.designpatterns.adapter.objectadapter;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-07 22:40
 **/
public class VoltageAdapter  implements Voltage5V {

    private Voltage220V voltage220V;

    public VoltageAdapter() {
        voltage220V = new Voltage220V();
    }

    @Override
    public int output5V() {
        if ((voltage220V != null)) {
            int src = voltage220V.output220V();
            System.out.println("使用对象适配器，进行适配~~");
            int dest = src / 44;
            System.out.println("适配完成，转换后电压为" + dest + "V");
            return dest;
        }
        throw new RuntimeException("适配源注入失败！");
    }
}
